<?php include("includes/function.php"); ?>
<!DOCTYPE html>
<html lang="en">
  
  <head>
    <meta charset="utf-8">
    <title>SMS Gateway</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <!-- Le styles -->
    <link type="text/css" href="css/bootstrap.css" rel="stylesheet">
    <link type="text/css" href="css/validationEngine.jquery.css" rel="stylesheet">
    <link type="text/css" href="css/custom-theme/jquery-ui-1.10.0.custom.css" rel="stylesheet" />
    <!-- <link type="text/css" href="css/font-awesome.min.css" rel="stylesheet" /> -->
    <link type="text/css" href="css/DT_bootstrap.css" rel="stylesheet">
    <link type="text/css" href="css/bootstrap-responsive.css" rel="stylesheet">
    <link type="text/css" href="css/bootstrap-modal.css" rel="stylesheet">
    <link type="text/css" href="css/bootstrap-tag.css" rel="stylesheet">
    <link type="text/css" href="css/font-awesome.css" rel="stylesheet">
    
    <style type="text/css">
      body {
        padding-top: 60px;
        padding-bottom: 20px;
      }
      
      .row-fluid {
        min-height: 600px;
      }
      
      .sidebar-nav {
        padding: 9px 0;
      }
      
      .logo-unud{
        margin-right: 20px;
      }
      
      .grey-bg{
        background-color: #f5f5f5;
      }
      
      #footer{
        font-size: 11px;
        padding: 0px;
        margin: 0px;
      }
      
      .ui-datepicker .ui-datepicker-prev, 
      .ui-datepicker .ui-datepicker-next
      {
        display:none;
      }
      .navbar .pull-right > li > .dropdown-menu, .navbar .nav > li > .dropdown-menu.pull-right {
        max-height: 300px;
        overflow: auto;
        width: 250px;
      }
      li.notif_inbox {
        border-bottom: 1px dashed #CCC;
      }
      li.notif_inbox:last-child {
        border-bottom: none;
      }
    </style>
    
    <link type="text/css" href="css/bootstrap-responsive.css" rel="stylesheet">
    <!-- <link href="css/pesan.css" rel="stylesheet">   -->
    <style type="text/css">
    body{
      padding-top: 60px;
      padding-bottom: 40px;
    }
    .sidebar-nav{
      padding: 0;
      position: fixed;
      left: 0;
      top: 0;
      height: 100%;
      width: 300px;
    }
    .sidebar-nav ul{
      margin-top: 40px;
    }
    .nav-header {
      padding-top: 10px;
      padding-bottom: 10px;
      background-color: #CCC;
    }
    </style>  
    
    <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

    <!-- Fav and touch icons -->    
    <link rel="shortcut icon" href="ico/favicon.ico">
    
    <script src="js/jquery.js"></script>
    <script>
      var coba = [];
      function alertModal(pesan, lokasi){
        var pesan_modal = {
            pesan: pesan,
            lokasi: lokasi
        };

        $.ajax({
            type: "POST",
            url: "alert_modal.php",
            data: pesan_modal, 
            cache: false, 
            success: function(msg){
                $("#tampil-modal").html(msg);
            } 
        });   
      }
    </script>
  </head>

  <body>

    <div class="navbar navbar-fixed-top">
      <div class="navbar-inner">
        <div class="container-fluid">
          <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </a>
          <a class="brand" href="#"><img src="img/seo-logo.png" style="margin-top:-7px; margin-bottom:-5px;"></a>
          <div class="nav-collapse collapse">            
            <ul class="nav pull-right">             
              <!-- Read about Bootstrap dropdowns at http://twitter.github.com/bootstrap/javascript.html#dropdowns -->
              <?php 
              ?>
              <li class="dropdown">
                <?php  
                  $sql_check_inbox = "SELECT * FROM inbox where status = '1'";
                  $query_check_inbox = mysql_query($sql_check_inbox);
                  $jumlah_check_inbox = mysql_num_rows($query_check_inbox);
                  if ($jumlah_check_inbox == 0) {
                    $jumlah_check_inbox = "";
                ?>
                  <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="icon-envelope icon-white"></i><b class="caret"></b></a>
                <?php } else { ?>
                  <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="icon-envelope icon-white"></i> <span id="badge_inbox" class="badge badge-important"><?php echo $jumlah_check_inbox ?></span><b class="caret"></b></a>
                  <ul class="dropdown-menu">
                    <?php  
                      $query_check_inbox = mysql_query($sql_check_inbox);
                      while ($result_check_inbox = mysql_fetch_array($query_check_inbox)) {
                        $sql_cek_kontak = "SELECT * FROM tb_kontak_rincian where no_hp='$result_check_inbox[SenderNumber]'";
                        $query_cek_kontak = mysql_query($sql_cek_kontak);
                        $banyak_row = mysql_num_rows($query_cek_kontak);

                        if($banyak_row > 0){
                          $query_cek_kontak = mysql_query($sql_cek_kontak);
                          $cek_kontak = mysql_fetch_array($query_cek_kontak);
                            $sql = "SELECT * FROM tb_kontak WHERE id_kontak = '$cek_kontak[id_kontak]'";
                            $query = mysql_query($sql);
                            $baris = mysql_fetch_array($query);

                            $nama_kontak = substr($baris['nama_kontak'], 0, 20);

                            if (strlen($baris['nama_kontak']) > 20) {
                              $nama_kontak .= "...";
                            }
                        } else{
                          $nama_kontak = $result_check_inbox['SenderNumber'];
                        }
                    ?>
                      <li data-id="<?php echo $result_check_inbox['ID'] ?>" class="notif_inbox">
                        <a href="#">
                          <strong><?php echo $nama_kontak; ?></strong>
                          <p>
                            <?php 
                              echo substr($result_check_inbox['TextDecoded'], 0, 25); 
                              if (strlen($result_check_inbox['TextDecoded']) > 25) {
                              echo "...";
                            }
                            ?>
                          </p>
                        </a>
                      </li>
                    <?php
                      }
                    ?>
                  </ul>
                <?php } ?>
              </li>

              <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="icon-user icon-white"></i> Karis Kung <b class="caret"></b></a>
                <ul class="dropdown-menu">
                  <li>
                    <a href="#"><img src="img/user_pp.jpeg" class="img-rounded"> Karis Kung</a>                  
                  </li>             
                  <li class="divider"></li>                                  
                  <li><a href="/smsgateway" class="logout">Logout</a></li>    
                </ul>
              </li>
            </ul>
          </div><!--/.nav-collapse -->          
        </div>
      </div>
    </div>

    <div class="container-fluid">
      <div id="tampil-modal"></div>
      <div id="tampil-modal-lain"></div>
      <div id="tampil-modal-kontak"></div>
      <div class="row-fluid">
            <div class="span3">
            
              <div class="well sidebar-nav">
                <ul class="nav nav-list">
                  <!-- <li class="nav-header">General</li>
                  <li <?php selectedMenu('home'); ?>><a href="home.php">Home</a></li> -->
                  <li class="nav-header">Pesan</li>
                  <li <?php selectedMenu('compose'); ?>><a href="compose.php"><i class="icon icon-edit"></i>Pesan Baru</a></li>
                  <li <?php selectedMenu('inbox'); ?>><a href="inbox.php"><i class="icon icon-envelope"></i>Pesan Masuk</a></li>    
                  <li <?php selectedMenu('draft'); ?>><a href="draft.php"><i class="icon icon-folder-open"></i>Pesan Tersimpan</a></li>
                  <li <?php selectedMenu('outbox'); ?>><a href="outbox.php"><i class="icon icon-plane" style="margin-right: 20px !important"></i>Pesan Terkirim</a></li>
                  <li <?php selectedMenu('contact'); ?>><a href="kontak.php"><i class="icon icon-user" style="margin-right: 20px !important"></i>Kontak</a></li>
                  <!-- <li class="nav-header">Fitur</li>
                  <li <?php selectedMenu('broadcast'); ?>><a href="broadcast.php">Broadcast</a></li>  -->
                  <li class="nav-header">Pengaturan</li>
                  <li <?php selectedMenu('gammu'); ?>><a href="gammu.php">Gammu</a></li>    
                  <!-- <li <?php selectedMenu('host'); ?>><a href="host.php">Koneksi</a></li> -->
                  <!-- <li <?php selectedMenu('privilege'); ?>><a href="privilege.php">Hak Akses Format</a></li>
                  <li <?php selectedMenu('database'); ?>><a href="database.php">Database</a></li> -->
                  <li <?php selectedMenu('service'); ?>><a href="service.php">Service Status</a></li>
                  <!-- <li <?php selectedMenu('pulsa'); ?>><a href="pulsa.php">Cek Pulsa</a></li> -->
                  <!-- <li class="nav-header">Operasi</li>
                  <li <?php selectedMenu('format'); ?>><a href="format.php">Format SMS</a></li>
                  <li class="nav-header">Master</li>
                  <li <?php selectedMenu('agregat'); ?>><a href="agregat.php">Master Operasi Agregat</a></li>
                  <li <?php selectedMenu('karakter'); ?>><a href="karakter.php">Master Karakter</a></li>
                  <li <?php selectedMenu('provider'); ?>><a href="provider.php">Master Provider</a></li> -->
                </ul>
              </div><!--/.well -->
            </div>